package com.munhrasoft.dinamica.business.entities;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;

@Entity
@NamedQueries(value = {
		@NamedQuery(name = "findAllClientes", query = "SELECT c FROM Cliente c"),
		@NamedQuery(name = "findByProponente", query = "SELECT c FROM Cliente c WHERE lower(c.proponente) "
				+ "LIKE :name") })
@SequenceGenerator(name = "clienteSeq", initialValue = 1, allocationSize = 1)
public class Cliente {

	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "clienteSeq")
	private Long id;
	private String proponente;
	private String cpf;
	private String email;
	private String telCelular;
	private String telComercial;
	private String conjuge;
	private String cpfConjuge;
	private String emailConjuge;
	private String telCelularConj;
	private String telComercialConj;
	private String residencia;

	@OneToMany(fetch = FetchType.LAZY, cascade = CascadeType.ALL)
	private List<Imovel> imoveis;

	@Override
	public boolean equals(Object obj) {
		if (this.getId() == ((Cliente) obj).getId()) {
			return true;
		} else {
			return false;
		}
	}

	public String getTelCelular() {
		return telCelular;
	}

	public void setTelCelular(String telCelular) {
		this.telCelular = telCelular;
	}

	public String getTelComercial() {
		return telComercial;
	}

	public void setTelComercial(String telComercial) {
		this.telComercial = telComercial;
	}

	public String getConjuge() {
		return conjuge;
	}

	public void setConjuge(String conjuge) {
		this.conjuge = conjuge;
	}

	public String getCpfConjuge() {
		return cpfConjuge;
	}

	public void setCpfConjuge(String cpfConjuge) {
		this.cpfConjuge = cpfConjuge;
	}

	public String getEmailConjuge() {
		return emailConjuge;
	}

	public void setEmailConjuge(String emailConjuge) {
		this.emailConjuge = emailConjuge;
	}

	public String getTelCelularConj() {
		return telCelularConj;
	}

	public void setTelCelularConj(String telCelularConj) {
		this.telCelularConj = telCelularConj;
	}

	public String getTelComercialConj() {
		return telComercialConj;
	}

	public void setTelComercialConj(String telComercialConj) {
		this.telComercialConj = telComercialConj;
	}

	public String getResidencia() {
		return residencia;
	}

	public void setResidencia(String residencia) {
		this.residencia = residencia;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getProponente() {
		return proponente;
	}

	public void setProponente(String proponente) {
		this.proponente = proponente;
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public List<Imovel> getImoveis() {
		return imoveis;
	}

	public void setImoveis(List<Imovel> imoveis) {
		this.imoveis = imoveis;
	}

}
